var OS_globalVar = {
    OSMobile: {},
    OSPC: {},
    isMobile: false,
    isPC: false
}
var browser;
document.getElementById("face_img").onselectstart = function () {
    return false;
};
document.getElementById("face_img").ondragstart = function () {
    return false;
};
window._bd_share_config = {
    "common": {
        "bdSnsKey": {},
        "bdText": "",
        "bdMini": "1",
        "bdMiniList": false,
        "bdPic": "",
        "bdStyle": "0",
        "bdSize": "24"
    }, "share": {}
};
$(function () {
    $("#zb-comm-con").niceScroll({
        cursorcolor: "#d24441",
        cursoropacitymax: 1,
        touchbehavior: false,
        cursorwidth: "5px",
        cursorborder: "0",
        cursorborderradius: "0",
        autohidemode: true,
        mousescrollstep: 80
    });
    $(".zb-praise ul.praise-face li img").click(praiseClick);//点赞事件
    $(".comm-loading .loading_next").on("click", loadComment);//加载更多评论
    $("#zb-comm-con").focus(conFocus);//文本框获得焦点事件
    $("#zb-comm-con,.comment-form input[type='text']").blur(checkParamBlur);//参数校验失去焦点事件

})

function demoDownload() {
    if (!globalVar.demoDownloadTem) {
        return false;
    }
    globalVar.demoDownloadTem = false;
    var $this = $(this);
    $this.text("生成链接中...");
    $.ajax({
        url: "/article/getDownLoadUrl.zb",
        type: "POST",
        dataType: "JSON",
        data: {artId: globalVar.artId}
    }).done(function (res) {
        if (res && res.success) {
            window.location.href = res.data;
        } else {
            msg(res.msg || "生成下载链接失败,请刷新页面重试！");
        }
    }).fail(function () {
        msg("生成下载连接失败！");
    }).always(function () {
        $this.html("<i class='fa fa-cloud-download fa-lg'></i> 下载资源 ");
        globalVar.demoDownloadTem = true;
    })
}

function recordCount(artId) {
    $.post("/article/recordArtCount.zb", {artId: artId});
}

function loadPraise(type) {
    var artId = getUrlParm("id");
    if (!type && !artId) {
        msg("参数错误，加载点赞失败！");
        return false;
    }
    $.ajax({
        url: "../praise/getPraiseByArtId.zb",
        type: "POST",
        dataType: "JSON",
        data: {artId: artId, type: type}
    }).done(function (data) {
        if (data && data.success && data.data && data.data.length == 5) {
            var arr = data.data;
            var $praise = $(".zb-praise ul.praise-face");
            for (var i = 0; i < arr.length; i++) {
                $praise.find("li.pa-" + arr[i].praise_type + " .pCount").text(arr[i].praise_count);
            }
        } else {
            msg(data.msg || "加载点赞失败！");
        }
    }).fail(function () {
        msg("可能由于网络等原因，加载点赞失败！");
    })
}

function praiseClick() {
    var $this = $(this);
    var praiseId = $this.attr("data-id");
    var artId = globalVar.artId;
    if (globalVar.doc_type != 2 && !(praiseId || artId)) {
        msg("参数错误，点赞失败!");
        return false;
    }
    $.ajax({
        url: "../praise/addPraise.zb",
        type: "POST",
        dataType: "JSON",
        data: {artId: artId, praiseId: praiseId, type: globalVar.doc_type}
    }).done(function (res) {
        if (res && res.success) {
            var $countDom = $this.parent().find(".pCount");
            $countDom.text($countDom.text() - 0 + 1);
            msg(res.msg, fn);
        } else {
            msg(res.msg || "点赞失败！");
        }
    }).fail(function () {
        msg("可能由于网络等原因，点赞失败！");
    })

}

function loadArticle() {
    $.ajax({
        url: "/article/getArticleById.zb",
        type: "POST",
        data: {id: getUrlParm("id")},
        dataType: "JSON"
    }).done(function (data) {
        if (data && data.success) {
            globalVar.artId = data.data.id;
            recordCount(globalVar.artId);//简易记次
            var title = data.data.title;
            var msg = data.data.user_name + "&emsp;发表于：" + data.data.create_time + "&emsp;分类：" + data.data.blog_navbar_name;
            var content = data.data.content;
            $(".zb-title").text(title);
            $(".zb-msg").html(msg);
            $(".zb-ml-content").html(content);
            var $demo = $("#zb-main-left .zb-ml-demo");
            if (data.data.is_demo == 1) {
                $demo.find("a.OnLine").attr("href", data.data.demo_url).show();
                $demo.show();
            }
            if (data.data.is_download == 1) {
                $demo.find("a.download").show();
                $demo.show();
            }
            var $pre = $("pre.hljs");
            if ($pre.length > 0) {
                $pre.niceScroll({
                    cursorcolor: "#d24441",
                    cursoropacitymax: 1,
                    touchbehavior: false,
                    cursorwidth: "3px",
                    cursorborder: "0",
                    cursorborderradius: "0",
                    autohidemode: true,
                    mousescrollstep: 80
                });
            }
            //设置评论列表标题
            $(".zb-comm-l-title span.l-comm-title").text(title);
            //设置上一篇和下一篇
            var prevTitle = data.data.prevArticleTitle;
            var prevId = data.data.prevId;
            var nextTitle = data.data.nextArticleTitle;
            var nextId = data.data.nextId;
            var $prevBtn = $(".zb-praise ul.pre_next a.prev");
            var $nextBtn = $(".zb-praise ul.pre_next a.next");
            $prevBtn.data("id", prevId);
            $nextBtn.data("id", nextId);
            $prevBtn.find("span").text(prevTitle);
            $nextBtn.find("span").text(nextTitle);
            if (!prevId) {
                $prevBtn.css({"color": "#ccc", "cursor": "default"});
            } else {
                $prevBtn.click(function () {
                    window.location.href = "detail.html?id=" + prevId + "&t=" + new Date().getTime()
                })
            }
            if (!nextId) {
                $nextBtn.css({"color": "#ccc", "cursor": "default"});
            } else {
                $nextBtn.click(function () {
                    window.location.href = "detail.html?id=" + nextId + "&t=" + new Date().getTime()
                })
            }
            window._bd_share_config.common.bdPic = data.data.article_url + "/" + data.data.front_img;
            window._bd_share_config.common.bdText = data.data.title;
            window._bd_share_config.common.bdDesc = data.data.front_descr;
            with (document) 0[(getElementsByTagName('head')[0] || body).appendChild(createElement('script')).src = 'https://www.tuhongwei.com/static/api/js/share.js?v=89860593.js?cdnversion=' + ~(-new Date() / 36e5)]
        } else {
            msg(data.msg || "找不到对应的文章！");
        }
    }).fail(function () {
        msg("可能由于网路原因，加载失败！");
    }).always(function () {
        hideShade();
    })
}

function initCode() {
    $.ajax({
        url: "../verifCode/initGeetest.zb?t=" + (new Date()).getTime(),
        type: "POST",
        async: true,
        dataType: "json",
        success: function (data) {
            setTimeout(function () {
                initGeetest({
                    gt: data.gt,
                    challenge: data.challenge,
                    new_captcha: data.new_captcha,
                    offline: !data.success,
                    product: "popup",
                    width: "100%",
                    height: "34"
                }, bindSubmit);
            })
        }
    });
}

function bindSubmit(captchaObj) {
    $("#zb-comm-submit").on('click', {captchaObj: captchaObj}, submitBtnClick);
    captchaObj.appendTo("#verifCode");
    captchaObj.onError(function () {
        msg("验证出错啦，请稍后重试！");
    });
    captchaObj.onReady(function () {
        $("#verifWait").hide();
    });
}

function submitBtnClick(ev) {
    var id = getUrlParm("id")
    if (globalVar.doc_type != 2 && !id) {
        msg("找不到评论的文章，请刷新页面重试！");
        return false;
    }
    var param = checkParam();
    if (!$.isPlainObject(param)) {
        return false;
    }
    var result = ev.data.captchaObj.getValidate();
    if (!result) {
        $("#verifCode").attr("data-content", "请拖动滑块进行验证！").popover("show");
        return false;
    } else {
        $("#verifCode").popover("hide");
    }
    param.id = id;
    param.geetest_challenge = result.geetest_challenge;
    param.geetest_validate = result.geetest_validate;
    param.geetest_seccode = result.geetest_seccode;
    param.doc_type = globalVar.doc_type;
    if (!globalVar.submitComtTem) {
        return false;
    }
    globalVar.submitComtTem = false;
    var $this = $(this);
    $this.val("正 在 提 交 评 论 . . . . . .");
    getOsMsg();
    if (OS_globalVar.isPC) {
        $.extend(param, OS_globalVar.OSPC, {os_type: "PC"})
    } else {
        $.extend(param, OS_globalVar.OSMobile, {os_type: "Mobile"})
    }
    $.ajax({
        url: "/comment/addComment.zb",
        type: "POST",
        dataType: "JSON",
        contentType: "application/json",
        data: JSON.stringify(param)
    }).done(function (res) {
        if (res && res.success) {
            var osv = res.data.osv.split(",").join(" | ");
            $("#zb-comm-con").empty();
            var li = "<li class='zb-com-l-ul-li'>" +
                "    <div class='talk'>" +
                "        <img style='margin:5px 5px;' width='50px' height='50px' src='" + res.data.defaultHeader + "'>" +
                "        <div class='talk-head'>" +
                "            <span class='pull-left'>" + param.nickname + "</span>" +
                "            <span class='talk_time pull-left'>" + getCurDateTime() + "</span>" +
                "            <span class='OSV pull-left'>" + osv + "</span>" +
                "            <span class='pull-left'>审核中...</span>" +
                "        </div>" +
                "        <div class='tale_cont'>" + param.content + "</div>" +
                "    </div>" +
                "</li>";
            $(".zb-com-l-ul").prepend(li);
            ev.data.captchaObj.reset();
            var comment_user = {nickname: param.nickname, email: param.email, website: param.personal_website};
            localStorage.setItem("comment_user", JSON.stringify(comment_user));
            msg(res.msg);
        } else {
            ev.data.captchaObj.reset();
            msg(res.msg || "评论失败！");
        }
    }).fail(function () {
        ev.data.captchaObj.reset();
        msg("可能由于网络等原因，评论失败！");
    }).always(function () {
        globalVar.submitComtTem = true;
        $this.val("发 表 评 论");
    })
}

function checkParamBlur() {
    var id = $(this).attr("id");
    if (id == 'zb-comm-con') {
        var content = $("#zb-comm-con").html().trim()
        if (content && !/^(&nbsp;)+$/.test(content) && !/^(&nbsp;\s*)+$/.test(content)) {
            $(this).removeClass("form-control-error").popover("hide");
        } else {
            $(this).addClass("form-control-error").attr("data-content", "请输入评论内容").popover("show");

        }
    } else if (id == 'visitor_name') {
        var nickname = $("#visitor_name").val().trim();
        if (nickname && nickname.length <= 16) {
            $(this).removeClass("form-control-error").popover("hide");
        } else {
            $(this).addClass("form-control-error").attr("data-content", "姓名不能为空且长度不超过16个字符").popover("show");
        }
    } else if (id == 'visitor_email') {
        var email = $("#visitor_email").val().trim();
        if (/^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/.test(email)) {
            $(this).removeClass("form-control-error").popover("hide");
        } else {
            $(this).addClass("form-control-error").attr("data-content", "如果想收到回复，就输入正确的邮箱吧").popover("show");
        }
    }
}

function checkParam() {
    var passTerm = true;
    var param = {};
    param.content = $("#zb-comm-con").removeClass("form-control-error").html().trim();
    param.nickname = $("#visitor_name").removeClass("form-control-error").val().trim();
    param.email = $("#visitor_email").removeClass("form-control-error").val().trim();
    param.personal_website = $("#visitor_url").removeClass("form-control-error").val().trim();
    if (!param.content || /^(&nbsp;)+$/.test(param.content) || /^(&nbsp;\s*)+$/.test(param.content)) {
        $("#zb-comm-con").addClass("form-control-error").attr("data-content", "请输入评论内容").popover("show");
        return false;
    }
    if (!param.nickname || param.nickname.length > 16) {
        $("#visitor_name").addClass("form-control-error").attr("data-content", "姓名不能为空且长度不超过16个字符").popover("show");
        passTerm = false;
    }
    if (!/^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/.test(param.email)) {
        $("#visitor_email").addClass("form-control-error").attr("data-content", "如果想收到回复，就输入正确的邮箱吧").popover("show");
        passTerm = false;
    }
    if (passTerm) {
        param.website = $("#visitor_url").val().trim();
        return param;
    }
    return false;
}

function faceBtnClick() {
    var $faceUl = $("#face_ul");
    var status = $faceUl.attr("data_status");

    if (status == '0') {
        for (var i = 1; i <= 59; i++) {
            var li = "<li><img src='http://home.zhangbin.xin/static/img/face/comment/" + i + ".gif' width='29' height='29'/></li>";
            $faceUl.append(li);
        }
        $faceUl.slideDown();
        $faceUl.niceScroll({
            cursorcolor: "#d24441",
            cursoropacitymax: 1,
            touchbehavior: false,
            cursorwidth: "2px",
            cursorborder: "0",
            cursorborderradius: "0",
            autohidemode: true,
            mousescrollstep: 60
        });
        $faceUl.attr("data_status", "1")
    } else if (status == '1') {
        $faceUl.slideUp();
        $faceUl.attr("data_status", "2")
    } else {
        $faceUl.slideDown();
        $faceUl.attr("data_status", "1")
    }
    return false;
}

function faceUlLiClick() {
    $(this).parent().slideUp();
    $("#face_ul").attr("data_status", "2")
}

function faceUlImgClick() {
    var imgUrl = $(this).attr("src");
    $("#zb-comm-con").append("<img src='" + imgUrl + "' width='30px'>");
}

function conFocus() {
    if ($(window).width() <= 768 && $(".nav.navbar-static-top").is(":visible")) {
        navBarHide();
    }
    if ($(".comment-form .row").is(":hidden")) {
        $("#face_btn").on("click", faceBtnClick);
        $("#face_ul").on("click", "li", faceUlLiClick);
        $("#face_ul").on("click", "li img", faceUlImgClick);
        $("[data-toggle='popover']").popover();
        $("#face_img").slideDown();
        $(".comment-form .row").slideDown();
        initCode();//初始化页面的时候加载验证码
        var comment_user = localStorage.getItem("comment_user")
        if (comment_user) {
            var local_user = $.parseJSON(comment_user);
            $("#visitor_name").val(local_user.nickname);
            $("#visitor_email").val(local_user.email);
            $("#visitor_url").val(local_user.website);
        }

    }
}

function loadComment(e, f_type) {
    $(".zb-comment-list .loading-next-div").hide();
    $(".zb-comment-list .loading_wait").show();
    if (!f_type) {
        f_type = globalVar.doc_type;
    }
    var def = $.ajax({
        url: "../comment/getCommByArtId.zb",
        type: "POST",
        dataType: "JSON",
        data: {pageNum: globalVar.pageNum, id: getUrlParm("id"), type: f_type}
    });
    def.done(function (data) {
        if (data && data.list && data.list.length > 0) {
            var $comment = $(".zb-comment-list ul.zb-com-l-ul");
            for (var i = 0; i < data.list.length; i++) {
                var parentComment = data.list[i].parentComment;
                var subComment = data.list[i].subComment;
                var browser = parentComment.browser.split(",").join(" | ");
                var lis = "<li class='zb-com-l-ul-li'>" +
                    "        <div class='talk'>" +
                    "           <img style='margin:5px 5px;' width='50px' height='50px' src='" + parentComment.header_img + "'>" +
                    "        <div class='talk-head'>" +
                    "            <span class='pull-left'>" + parentComment.nickname + "</span>" +
                    "            <span class='talk_time pull-left'>" + parentComment.create_time + "</span>" +
                    "            <span class='OSV pull-left'>" + browser + "</span>" +
                    "        </div>" +
                    "        <div class='tale_cont'>" + parentComment.content + "</div>";
                for (var j = 0; j < subComment.length; j++) {
                    lis += "<div class='answer'>" +
                        "    <img style='margin:5px 5px' width='30px' src='" + subComment[j].header_img + "'>" +
                        "    <div class='answer-head'>" +
                        "       <span class='pull-left'>" + subComment[j].nickname + "</span>" +
                        "       <span class='pull-left'>" + subComment[j].create_time + "</span>" +
                        "    </div>" +
                        "    <div class='tale_cont'>" + subComment[j].content + "</div>" +
                        "</div>";
                }
                lis += "</div></li>";
                $comment.append(lis);
            }
            globalVar.pageNum++;
            if (f_type) {
                globalVar.doc_type = f_type;
            }
            if (data.isLastPage) {
                $(".comm-loading .loading_next").off();
                $(".comm-loading .loading_next").text("没有更多评论了！⊙﹏⊙")
            }
            $("#zb-main-left .zb-comm-l-title span.l-comm-count").html("&emsp;共 " + data.total + " 条");
        } else if (data && data.list && data.list.length == 0) {
            $(".zb-main-left .zb-comm-l-title span.l-comm-count").html("&emsp;共 " + data.total + " 条");
            $(".comm-loading .loading_next").off();
            $(".comm-loading .loading_next").text("快去抢沙发吧! ^_^")
        } else {
            msg("评论加载失败！");
        }
    })
    def.fail(function () {
        msg("可能由于网络等原因，评论加载失败！");
    })
    def.always(function () {
        $(".zb-comment-list .loading_wait").hide();
        $(".zb-comment-list .loading-next-div").show();
    })
}

function getCurDateTime() {
    var date = new Date();
    var year = date.getFullYear();
    var month = date.getMonth() + 1;
    var day = date.getDate();
    var hour = date.getHours();
    var min = date.getMinutes();
    var second = date.getSeconds();
    if (month < 10) {
        month = "0" + month;
    }
    if (day < 10) {
        day = "0" + day;
    }
    if (hour < 10) {
        hour = "0" + hour;
    }
    if (min < 10) {
        min = "0" + min;
    }
    if (second < 10) {
        second = "0" + second;
    }
    return year + "-" + month + "-" + day + " " + hour + ":" + min;
}

function pcBrowserVersion(ua) {
    var isIE = ua.indexOf("compatible") > -1 && ua.indexOf("MSIE") > -1; //判断是否IE<11浏览器
    var isEdge = ua.indexOf("Edge") > -1 && !isIE; //判断是否IE的Edge浏览器
    var isIE11 = ua.indexOf('Trident') > -1 && ua.indexOf("rv:11.0") > -1;//判断是否是ie11
    if (isIE) {
        var reIE = new RegExp("MSIE (\\d+\\.\\d+);");
        reIE.test(ua);
        var fIEVersion = parseFloat(RegExp["$1"]);
        if (fIEVersion == 7) {
            return ['IE', 7];
        } else if (fIEVersion == 8) {
            return ['IE', 8];
        } else if (fIEVersion == 9) {
            return ['IE', 9];
        } else if (fIEVersion == 10) {
            return ['IE', 10];
        } else {
            return ['IE', 6];//IE版本<=7
        }
    } else if (isEdge) {
        return ['IE', 'edge'];//edge
    } else if (isIE11) {
        return ['IE', 11]; //IE11
    } else {//不是ie浏览器
        if (/Firefox/g.test(ua)) {
            ua = ua.split(" ");
            ret = "Firefox|" + ua[ua.length - 1].split("/")[1];
        } else if (/MSIE/g.test(ua)) {
            ua = ua.split(";");
            ret = "IE|" + ua[1].split(" ")[2];
        } else if (/Opera/g.test(ua)) {
            ua = ua.split(" ");
            ret = "Opera|" + ua[ua.length - 1].split("/")[1];
        } else if (/Chrome/g.test(ua)) {
            ua = ua.split(" ");
            ret = "Chrome|" + ua[ua.length - 2].split("/")[1];
        } else if (/^apple\s+/i.test(navigator.vendor)) {
            ua = ua.split(" ");
            ret = "Safair|" + ua[ua.length - 2].split("/")[1];
        } else {
            ret = ["未知浏览器", "未知版本号"];
        }
        return ret.split("|")
    }
}

function pcOS(ua) {
    var isWin = (navigator.platform == "Win32") || (navigator.platform == "Windows" || (navigator.platform == "Win64"));
    var isMac = (navigator.platform == "Mac68K") || (navigator.platform == "MacPPC") || (navigator.platform == "Macintosh") || (navigator.platform == "MacIntel");
    if (isMac) return "Mac";
    var isUnix = (navigator.platform == "X11") && !isWin && !isMac;
    if (isUnix) return "Unix";
    var isLinux = (String(navigator.platform).indexOf("Linux") > -1);
    if (isLinux) return "Linux";
    if (isWin) {
        var isWin2K = ua.indexOf("Windows NT 5.0") > -1 || ua.indexOf("Windows 2000") > -1;
        if (isWin2K) return "Win2000";
        var isWinXP = ua.indexOf("Windows NT 5.1") > -1 || ua.indexOf("Windows XP") > -1;
        if (isWinXP) return "WinXP";
        var isWin2003 = ua.indexOf("Windows NT 5.2") > -1 || ua.indexOf("Windows 2003") > -1;
        if (isWin2003) return "Win2003";
        var isWinVista = ua.indexOf("Windows NT 6.0") > -1 || ua.indexOf("Windows Vista") > -1;
        if (isWinVista) return "WinVista";
        var isWin7 = ua.indexOf("Windows NT 6.1") > -1 || ua.indexOf("Windows 7") > -1;
        if (isWin7) return "Win7";
        var isWin8 = ua.indexOf("Windows NT 6.2") > -1 || ua.indexOf("Windows 8") > -1;
        if (isWin8) return "Win8";
        var isWin10 = ua.indexOf("Windows NT 10.0") > -1 || ua.indexOf("Windows 10") > -1;
        if (isWin10) return "Win10";
    }
    return "未知系统";
}

function mobileOS() {
    //判断数组中是否包含某字符串
    Array.prototype.contains = function (needle) {
        for (i in this) {
            if (this[i].indexOf(needle) > 0)
                return i;
        }
        return -1;
    }
    var md = new MobileDetect(ua);//初始化mobile-detect
    var os = md.os();//获取系统
    var version = "";//获取系统版本
    var mobile = ""; //获取手机类型
    if (os == "iOS") {//ios系统的处理
        // os = md.os() + md.version("iPhone");
        version = md.version("iPhone");
        mobile = md.mobile();
    } else if (os == "AndroidOS") {//Android系统的处理
        //os = md.os() + md.version("Android");
        version = md.version("Android");
        var sss = ua.split(";");
        var i = sss.contains("Build/");
        if (i > -1) {
            mobile = sss[i].substring(0, sss[i].indexOf("Build/"));
        }
    }
    OS_globalVar.OSMobile.OS = os;
    OS_globalVar.OSMobile.version = version;
    OS_globalVar.OSMobile.mobile = mobile;
    OS_globalVar.OSMobile.qq = browser.versions.qq ? "1" : "0";
    OS_globalVar.OSMobile.weixin = browser.versions.weixin ? "1" : "0";
    OS_globalVar.OSMobile.iPad = browser.versions.iPad ? "1" : "0";
}

function getOsMsg() {
    var local_OS_globalVar = localStorage.getItem("OS");
    if (local_OS_globalVar == null) {
        browser = {
            versions: function () {
                return {
                    trident: ua.indexOf('Trident') > -1, //IE内核
                    presto: ua.indexOf('Presto') > -1, //opera内核
                    webKit: ua.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
                    gecko: ua.indexOf('Gecko') > -1 && ua.indexOf('KHTML') == -1,//火狐内核
                    mobile: !!ua.match(/AppleWebKit.*Mobile.*/), //是否为移动终端
                    ios: !!ua.match(/\(i[^;]+;( U;)? CPua.+Mac OS X/), //ios终端
                    android: ua.indexOf('Android') > -1 || ua.indexOf('Adr') > -1, //android终端
                    iPhone: ua.indexOf('iPhone') > -1, //是否为iPhone或者QQHD浏览器
                    iPad: ua.indexOf('iPad') > -1, //是否iPad
                    webApp: ua.indexOf('Safari') == -1, //是否web应该程序，没有头部与底部
                    weixin: ua.indexOf('MicroMessenger') > -1, //是否微信 （2015-01-22新增）
                    qq: /YYB_D\s*QQ/.test(ua) //是否QQ
                };
            }(),
            language: (navigator.browserLanguage || navigator.language).toLowerCase()
        }
        if (browser.versions.mobile) {//移动端
            OS_globalVar.isMobile = true;
            mobileOS();
        } else {//PC端
            OS_globalVar.isPC = true;
            var browserVersion = pcBrowserVersion(ua);
            OS_globalVar.OSPC.browser = browserVersion[0];
            OS_globalVar.OSPC.version = browserVersion[1];
            OS_globalVar.OSPC.OS = pcOS(ua);
        }
        localStorage.setItem("OS", JSON.stringify(OS_globalVar));
    } else {
        OS_globalVar = $.parseJSON(local_OS_globalVar);
    }
}



